<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/10/17 0017
 * Time: 上午 11:06
 */

namespace app\api\tool;


use think\Request;

class Btr
{
  


    public function search($car_num,$vin='',$en='',$car_type='02',$is_company=0,$company_car_type=0){
        $param['car_num']=$car_num;
        $param['vin']=$vin;
        $param['en']=$en;
        $param['is_show_fee']=1;
        $param['is_reset']=1;
        $param['is_company']=1;
        $param['car_type']=$car_type;
        $param['is_company']=$is_company;
        $param['company_car_type']=$company_car_type;
        $res=http_request_center("api/btr/search",$param);
        if(!$res){
            return ['code'=>0,'msg'=>'请求控制中心失败！'];
        }
        
        //保存查询记录
        $service=service('BtrSearchMember');
        $search=[
            'car_num'=>$car_num,
            'vin'=>$vin,
            'en'=>$en,
            'car_type'=>$car_type,
        ];
        $member=Client::$member;
        $platform=Client::$platform;
        $search['member_id']=$member['id'];
        $search['platform_id']=$platform['id'];
        $search['ip']=Request::instance()->ip();
        $search['code']=$res['code'];
        $search['msg']=$res['msg'];
        $search['record_num']=isset($res['data']['record_num'])?$res['data']['record_num']:0;
        $service->add($search);
        return $res;
    }
}